package vcp.views;

import java.awt.event.ActionListener;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JOptionPane;

import client.Message;

import vcp.common.AbstractView;
import vcp.common.IView;
import vcp.gui.forms.CheckOutForm;

/**
 * Checkout view 
 *
 */
public class CheckOutView  extends AbstractView implements IView,Observer{
    CheckOutForm checkOutForm;	
    public CheckOutView(){
    	checkOutForm = new CheckOutForm();
    }
    
	@Override
	public void addController(Object obj) {
		checkOutForm.getBtnCheckOut().addActionListener((ActionListener)obj);		
	}
	
	@Override
	public void update(Observable arg0, Object arg) {
		Message tempMsg = (Message)arg;  

		switch(tempMsg.getMsg())
		 {
		 	case "CheckOut":
		
		 		if(tempMsg.isStatus())
		 		{
		 			JOptionPane.showMessageDialog(null , "Thank You For Parking With Us!");
		 		}	
		 		else
		 		{
		 			JOptionPane.showMessageDialog(null,"Failed Entering Lot " + tempMsg.getStatusMsg(),"DATABASE ERROR",JOptionPane.ERROR_MESSAGE);
		 		}
		 		break;
		 }
	}

	public CheckOutForm getForm() {
		return checkOutForm;
	}

}
